# -*- conding:utf-8 -*-
import config
import aliyun_api.domain_info as domain_info
import aliyun_api.all_domain as all_domain
import public.dingding as dingding


def get_day(key,secret,domain):
    return domain_info.get_domain_info(key,secret,domain)['ExpirationCurrDateDiff']


if __name__ == '__main__':
    send_content = '域名有效期监测：'
    for i in config.ali_auth:
        for m in all_domain.get_doamin(i['key'],i['secret'])['Data']['Domain']:
            day = get_day(i['key'],i['secret'],m['DomainName'])
            print({'domain':m['DomainName'],'day': day})
            if day <= 100:
                send_content = send_content + '\n' + '域名：' +  str(m['DomainName']) + '有效期：' + str(day)

    dingding.run(send_content)